<template>
    <div>
         <el-table :data="tableData" border  style="width: 100%">
            <el-table-column v-for="col in tableCols" :key="col.id"  :prop="col.prop"
            :label="col.label">
            </el-table-column>
        </el-table>
        <el-pagination class="pageinfo" background layout="total, prev, pager, next" limit='5'
          @current-change='changeCurrentPage'
          :total="totals">
        </el-pagination>
        <el-button class='goback' type='primary' style="margin-top: 80px;" @click="goback">返回</el-button>
    </div>
 
</template>

<script>
  export default {
    data() {
      return {
        tableData: [],
        tableCols: [
            {id: 1, prop: 'phone', label: '手机'}, {id: 2, prop: 'name', label: '姓名/法号'}, {id: 3, prop: 'sex', label: '性别'},
            {id: 4, prop: 'registerTime', label: '注册时间'}, {id: 5, prop: 'nickname', label: '微信昵称'}, {id: 6, prop: 'address', label: '地址'},
            {id: 7, prop: 'merit', label: '功德'}, {id: 8, prop: 'eventSum', label: '主活动参与次数'}, {id: 9, prop: 'scheduleSum', label: '日程事件参与次数'}
        ],
        currentPage: 1,
        totals: 0
      }
    },
    mounted() {
      this.getTableData()
    },
    methods: {
     
      getTableData() {
         let type = this.$route.query.type
         let param = {
           page: this.currentPage,
           limit: 8
         };
         let xname = this.$route.query.xName
         if(type == 'date') {
            let xais = ['一到两次', '三到五次', '六到八次', '九到十次', '超过十次']
           switch(xname) {
             case '一到两次': param.minSchedule = 1;param.maxSchedule = 2;break;
             case '三到五次': param.minSchedule = 3;param.maxSchedule = 5;break;
             case '六到八次': param.minSchedule = 6;param.maxSchedule = 8;break;
             case '九到十次': param.minSchedule = 9;param.maxSchedule = 10;break;
             case '超过十次': param.minSchedule = 11;param.maxSchedule = '';break;
             default: break
           }
           
         } else {
           switch(xname) {
             case '一次': param.eventTotal = 1;break;
             case '两次': param.eventTotal = 2;break;
             case '三次': param.eventTotal = 3;break;
             case '四次': param.eventTotal = 4;break;
             case '五次': param.eventTotal = 5;break;
             case '五次以上': param.eventTotal = 6;break;
             default: break
           }
           
         }
         this.$api.apiStatisMainDetail(param, res => {
           if(res.data != null)
            this.tableData = res.data
            this.tableData.forEach(item => {
              let {province, city, state} = item
              item.address = province + city
            })
            this.totals = res.pageInfo.total
         })
      },
      changeCurrentPage(page) {
          this.currentPage = page
          this.getAdminList()
      },
      goback() {
        this.$router.go(-1)
      }
    }
  }
</script>
<style lang="scss">

</style>
